USE S19;
GO

CREATE TABLE Company(
	Id INT IDENTITY(1,1) PRIMARY KEY
	, Name NVARCHAR(128) NOT NULL
);
GO

CREATE TABLE Workers (
	Id INT IDENTITY(1, 1) PRIMARY KEY
	, CompanyId INT FOREIGN KEY REFERENCES Company (Id)
	, Name NVARCHAR (32) NOT NULL
	, Surname NVARCHAR (32) NOT NULL
);
GO

CREATE TABLE JobTitles(
	Id INT IDENTITY(1,1) PRIMARY KEY
	, Title NVARCHAR(32) NOT NULL UNIQUE
);



PRINT NEWID();

DROP TABLE Posts;

CREATE TABLE Posts(
	Id UNIQUEIDENTIFIER PRIMARY KEY DEFAULT NEWSEQUENTIALID() --NEWID()
	, UserId INT FOREIGN KEY REFERENCES Users(Id) NOT NULL
	, Post TEXT NOT NULL
);

GO 
SELECT * FROM Posts;
SELECT * FROM Users;

INSERT INTO Posts (UserId, Post)  VALUES (11, N'Some post 3');
SELECT * FROM Posts;


SELECT * FROM Users;
SELECT * FROM Users ORDER BY ID;
SELECT * FROM Users ORDER BY ID ASC; -- from small to bigger
SELECT * FROM Users ORDER BY ID DESC; --descending
SELECT * FROM Users ORDER BY Name DESC;

SELECT * FROM fn_helpcollations(); -- DB or TABLE COLLATION

